// 导入3个页面
// import AdminView from "../views/admin/AdminView";
//   导入useselector
import { useSelector } from "react-redux";

import LoginView from "../views/LoginView";
import NoMatch from "../views/NoMatch";
// 导入权限组件
import Private from "../utils/Private";
// 导入useRoutes
import { useRoutes } from "react-router-dom";
// 导入useState
import { useState } from "react";
// 导入加载组件
import LazyLoad from "../utils/LazyLoad";
const AdminView = LazyLoad('/views/admin/AdminView');

// 导入RouterView
function RouterView() {
  const {routeList} = useSelector((state:any)=>state.auth);

  // 路由配置
const routes = [
  {path:"/",element:<LoginView/>},
  {path:"/admin/*",element:<Private>{AdminView}</Private>,children:routeList},
  {path:"*",element:<NoMatch/>}
]
  const element = useRoutes(routes);
  return ( <>{element}</> );
}

export default RouterView;
